#ifndef SCANNER_H
#define SCANNER_H

#include <QObject>
#include <QAtomicInt>
#include <QList>
#include <QPair>
#include <QString>

// 简化导出宏
#if defined(SCANNER_LIBRARY)
#define SCANNER_EXPORT Q_DECL_EXPORT
#else
#define SCANNER_EXPORT Q_DECL_IMPORT
#endif

class SCANNER_EXPORT Scanner : public QObject
{
    Q_OBJECT
public:
    explicit Scanner(QObject *parent = nullptr);
    ~Scanner();

    void startScan(const QString &folderPath);
    void stopScan();
    bool saveResult(const QString &filePath);

signals:
    void fileScanned(const QString &name, qint64 size);
    void scanFinished();
    void scanStopped();

private:
    void scanDirectory(const QString &path);

    QAtomicInt m_stopFlag;
    QList<QPair<QString, qint64>> m_results;
    QThread *m_thread = nullptr;
};

#endif // SCANNER_H
